package meijuli.com.join51.business.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import meijuli.com.join51.business.R;
import meijuli.com.join51.business.model.OrderData;

import java.util.List;

/**
 * 请描述使用该类使用方法！！！
 *
 * @author wenqin 2017-05-02 17:27
 */

public class OrderDataAdapter extends RecyclerView.Adapter<OrderDataAdapter.Vh> {

    private List<OrderData> data;
    private LayoutInflater mInflater;

    public OrderDataAdapter(Context context, List<OrderData> data) {
        this.data = data;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public Vh onCreateViewHolder(ViewGroup parent, int viewType) {
        return new Vh(mInflater.inflate(R.layout.adapter_order_data, parent, false));
    }

    @Override
    public void onBindViewHolder(Vh holder, int position) {
        holder.title.setText(data.get(position).getTitle());
        holder.description.setText(data.get(position).getDescription());
    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }

    class Vh extends RecyclerView.ViewHolder {
        TextView title;
        TextView description;

        public Vh(View itemView) {
            super(itemView);
            title = itemView.findViewById(R.id.title);
            description = itemView.findViewById(R.id.description);
        }
    }
}
